<template>
    <view class="p-l-r">
        <template v-for="row in dataRows" :key="row.id">
            <view class="log-item">
                <view>{{ WALLET_LOG_TYPE[row.type] }}</view>
                <view class='m-t-10'>{{(row.type == 1 || row.type == 3) ? '+' : ''}}{{ (Number(row.amount) + Number(row.rewardAmount)).toFixed(2) }}元</view>
                <view class='m-t-10'>{{ parseTime(row.createTime) }}</view>
            </view>
        </template>
    </view>
    <LoadMore key-name="id" :api="pageApi" @finish="page" />
</template>

<script lang="ts" setup>
    import { WALLET_LOG_TYPE} from '@/constant'
    import { pageApi } from '@/api/Wallet';
    import LoadMore from '@/components/LoadMore/index.vue'
    import { parseTime } from '@/utils';
    import { navigateTo } from '@/utils/framework';
    import { ref } from 'vue';
    
    


    const dataRows = ref<any[]>([])

    function page(rows:any[]) {
        dataRows.value.push(...rows)
    }

    function nav(id:number, status:number) {
        navigateTo(status == 1 ? ('./charging/index?id=' + id) : ('./detail/index?id=' + id))
    }


</script>

<style lang="scss" src="./index.scss"></style>